<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.28.
   家居最新招标控制器($$)*/

!defined('Q_PATH') && exit;

class JiajubiddingController extends AController{

	public function filter_(&$arrMap){
		$arrMap['A.jiajubidding_title']=array('like',"%".Q::G('jiajubidding_title')."%");
		$arrMap['A.jiajubidding_realspace']=array('egt',intval(Q::G('jiajubidding_realspace')));
		$arrMap['A.jiajubidding_realprice']=array('egt',intval(Q::G('jiajubidding_realprice')));
		
		// 添加时间
		$this->getTime_('A.create_dateline',$arrMap);

		// 待审
		$this->getAudit_('A.jiajubidding_status',$arrMap);
	}

	public function index($sModel=null,$bDisplay=true){
		parent::index('jiajubidding',false);
		$this->display(Admin_Extend::template('jiaju','jiajubidding/index'));
	}

	protected function sqljoin_(){
		return "->joinLeft('".Q::C('DB_PREFIX')."jiajucompanyclass AS C','C.jiajucompanyclass_name AS space_name','A.jiajubidding_spaceid=C.jiajucompanyclass_id')".
			"->join('".Q::C('DB_PREFIX')."site AS D','D.site_name,D.site_domain','A.site_id=D.site_id')";
	}

	public function bEdit_(){
		// 招标属性
		$oJiajucompanyclass=Q::instance('JiajucompanyclassModel');
		$this->assign('arrStyleclass',$oJiajucompanyclass->getClass(52));
		$this->assign('arrSpaceclass',$oJiajucompanyclass->getClass(53));
		$this->assign('arrPriceclass',$oJiajucompanyclass->getClass(50));
		$this->assign('arrAreaclass',$oJiajucompanyclass->getClass(51));
	}

	public function edit($sMode=null,$nId=null,$bDidplay=true){
		$nId=intval(Q::G('value','G'));
		$this->bEdit_();
		parent::edit('jiajubidding',$nId,false);
		$this->display(Admin_Extend::template('jiaju','jiajubidding/add'));
	}

	public function update($sModel=null,$nId=null){
		$nId=Q::G('value');
		parent::update('jiajubidding',$nId);
	}

	public function forbid($sModel=null,$sId=null,$bApp=false){
		$nId=intval(Q::G('value','G'));
		parent::forbid('jiajubidding',$nId,true);
	}

	public function resume($sModel=null,$sId=null,$bApp=false){
		$nId=intval(Q::G('value','G'));
		parent::resume('jiajubidding',$nId,true);
	}

	public function clear_recycle($sModel=null,$sField='status'){
		parent::clear_recycle('jiajubidding',$sField);
	}

	public function foreverdelete_deep($sModel=null,$sId=null){
		$sId=Q::G('value');
		parent::foreverdelete_deep('jiajubidding',$sId);
	}

	public function foreverdelete($sModel=null,$sId=null,$bApp=false){
		$sId=Q::G('value');
		parent::foreverdelete('jiajubidding',$sId,true);
	}

	public function view_preview($sMode=null,$nId=null,$bDidplay=true){
		$nId=intval(Q::G('value','G'));
		parent::view_preview('jiajubidding',$nId,false);
		$this->display(Admin_Extend::template('jiaju','jiajubidding/viewpreview'));
	}

	public function save_preview($sMode=null,$nId=null){
		$nId=intval(Q::G('value','G'));
		parent::save_preview('jiajubidding',$nId);
	}

	public function save_previewstatus($sMode=null,$nId=null){
		$nId=intval(Q::G('value','G'));
		parent::save_previewstatus('jiajubidding',$nId);
	}

	public function getBiddingShow($arrValue){
		return 'http://'.$arrValue['site_domain'].'.114.ms/bidding-'.$arrValue['jiajubidding_id'].'.html';
	}

}
